# -*- coding:utf-8 -*-

import configparser as config
import traceback


class TimeoutError(Exception):
    pass


class ReadConfig:
    """
    读取配置文件
    """
    def __init__(self, path='', section=None):
        self.section = section
        self.config = config.ConfigParser()
        self.config.read(path)

    def get_sections(self):
        return self.config.sections()

    def read_config(self, section):
        result = {}
        try:
            config_args = self.config.items(section)
            # print(configArgs)
        except Exception as e:
            traceback.print_exc()
            return {}
        else:
            for (k, v) in config_args:
                result[k] = v
        return result
